%li.cast
  - actor = product_parameter.product
  - intervention = product_parameter.intervention
  - product = product_parameter.product

  - if intervention.participations.empty?
    = add_working_period_cost(product_parameter)
  - else
    - participation = product_parameter.participation if product_parameter.is_a?(InterventionDoer)
    - is_equipment = product.try(:tractor?) || product.try(:self_prepelled_equipment?)
    .periods
      - if (!participation.nil? && participation.has_period_with_nature?(nature: :preparation))
        .period
          .period-type
            = image_tag('intervention_participations/action-preparation.svg', class: "period-icon")
            %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.preparation')
          = add_working_period_cost(product_parameter, nature: :preparation)

      - if !participation.nil? && participation.has_period_with_nature?(nature: :travel) || product.try(:tractor?)
        .period
          .period-type
            = image_tag('intervention_participations/action-travel.svg', class: "period-icon")
            %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.travel')
          = add_working_period_cost(product_parameter, nature: :travel)

      - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || product.is_a?(Equipment)
        .period
          .period-type
            = image_tag('intervention_participations/action-intervention.svg', class: "period-icon")
            %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.intervention')
          = add_working_period_cost(product_parameter, nature: :intervention)

      - if !participation.nil? || is_equipment || product.is_a?(Equipment)
        .total
          %h3{ class: "total-label" }= t('labels.total')

          - if product.is_a?(Worker)
            = add_total_working_period(product_parameter)
          - elsif product.try(:tractor?)
            = add_total_working_period(product_parameter, natures: %i[travel intervention])
          - else
            = add_total_working_period(product_parameter, natures: %i[intervention])

  - variant = product_parameter.variant
  - if actor
    .picture
      - if actor.picture.file?
        = image_tag(actor.picture.url(:thumb))
      - elsif pictogram = actor.category.pictogram
        .picto{class: "picto-#{pictogram.gsub('_', '-')}"}
      - else
        .picto{class: 'picto-question'}

    .details
      %h3
        = link_to(actor.name, {controller: actor.class.table_name, action: :show, id: actor.id})
        = lights('stop') if product_parameter.dead and product_parameter.product.dead_at
      %p= product_parameter.name
      %p= product_parameter.model_name.human
      - if actor.is_a?(Product) && !actor.population_counting_unitary? && variant && product_parameter.quantity_unit_name && product_parameter.quantity
        %p
          - if product_parameter.is_population?
            = :x_thing.tl(x: product_parameter.quantity.round(2).l(precision: 0), thing: variant.unit_name.mb_chars.downcase)
          - elsif product_parameter.product.france_maaid && product_parameter.is_a?(InterventionInput)
            .details
              = product_parameter.product.france_maaid
            = product_parameter.quantity.round(2).l(precision: 0)
          - else
            = product_parameter.quantity.round(2).l(precision: 0)
  - elsif variant
    .picture
      - if variant.picture.file?
        = image_tag(variant.picture.url(:thumb))
      - elsif pictogram = variant.category.pictogram
        .picto{class: "picto-#{pictogram.gsub('_', '-')}"}
      - else
        .picto{class: 'picto-question'}

    .details
      %h3= link_to(variant.name, {controller: variant.class.table_name, action: :show, id: variant.id})
      %p= product_parameter.name
      %p= product_parameter.model_name.human
      - if !variant.population_counting_unitary?
        %p= :x_thing.tl(x: (product_parameter.quantity_value || 0).round(2).l(precision: 0),
                        thing: variant.unit_name.mb_chars.downcase)

  - else
    .picture
      .picto{class: 'picto-question'}
    .details
      %h3= product_parameter.name
      %p= product_parameter.model_name.human
